'use strict'; const axios= require('axios'); module.exports = { metadata: () => ({ name: 'GetUserDetails', properties: { account_number: {required: true,type: 'string'}, }, supportedActions: ['ok', 'error'] }), /** * invoke method gets called when the custom component state is executed in the dialog flow * @param {CustomComponentContext} context */ invoke:async (context) => { const {account_number} = context.properties(); try{ const user=await axios.get('sample.oracle.com'+`${account_number}`) if(user.data){ context .reply(`For your account number ${account_number}`) .reply( `your first-name is ${user.data.first_name} `) .reply(`your last-name is ${user.data.last_name}`) .reply(`your account balance is ${user.data.account_balance}`) context.transition('ok'); }else{ context.reply("Please give valid inputs"); context.transition('error'); } }catch(err){ context.reply('There might be some problem with bank, please try later!'); context.transition('error'); } } };