BitcoinBot
  • 23 Jul 2020
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

BitcoinBot

  • Dark
    Light
  • PDF

Article Summary

App ID and Webhook

  1. Create the app in Microsoft Bot Framework.

  2. Go to "Register a bot" tab and register your bot.You can get extra info about bot registration in Documentation tab.

  3. Get your personal Microsoft App ID application key and client_secret password.
    parol

  4. Put the received url of WEatherBot process, in "My bots" tab, in Messaging endpoint field. Instruction how to get webhook-url is here.
    mess_webhook

  5. Publish your bot by pressing button "Publish".

publish_bitcoin

After bot creation you need to publish it, otherwise the amount of visitors could be limited.

Pay attention, after bot publication there's a need to disable using of bot in group chats.

BitcoinBot creation

Clone the folder "BitcoinBot" with processes.
1(1)

In "Skype_sender" process, in Set skype_authorization node, in variable value
skype_authorization - put such construction

{{conv[{{process_id}}].ref[{{ref}}].parameter_ID}}

set_param_bitcoin

"Skype authorization" process designed to receive access_token for Skype API and, as far as expiration time of the key is 3600 sec, so after this expiration time process renews it and transfer valid access_token in "Skype storage" state diagram.

Using such construction as

{{conv[{{process_id}}].ref[{{ref}}].parameters_ID}}

we make a request to "Skype storage" state diagram and receive access_token.

Main_skype process
receives all messages, that coming to Bot's chat and first of all defines some action of user. For example, if user add Bot to his contacts, then process sends a greeting message to user.
Also, process defines bot's removing action and sends it to Bot removed. node.

Next, when user sends the message, Main_skype process is trying to renew request in BitcoinBot_SKYPE process and if there is no such request, it is creating new one with reference, equal to ({{skype_msgs.conversation.id}}) chat ID.

Thus we continue to chat with user in unique chat id - - {{skype_msgs.conversation.id}}.

modify

Requests come in BitcoinBot_SKYPE process from Main_skype process (with refrence equal to chat ID). If the user send start command then firstly he gets a message with currency select offer.

It allows to get updates (new commands or messages from user to bot's chat) from Main_skype process, where the request is in the CALLBACK logic node. So, after sending a message with currency select offer, request goes into waiting of this choice.

proc(1)

If the choice is not made in 1 minute (request will not be updated from Main_skype process), then we will send a timeout message - "Time expired. Try again. Please write start".

If the currency selection was made, we offer user to choose which currency will be shown - buying or selling and wait again in CALLBACK node.
proc_oper

The same if there is no appropriate selection, the timeout message will be sent.

If choice is made, we get the currency and send it in message.

And "Skype_sender" process sends messages in Skype.

Both processes (Main_skype and BitcoinBot_SKYPE) request to it through RPC logic.

Webhook sets up

Connect Main_skype process to Skype using webhook-url. To get webhook-url of process, select "Connect to messenger":

connect_to_messenger(1)

skype

Receive webhook-url of BitcoinBot process for SKYPE.

webhook

In Client ID empty field put your personal code for Microsoft App ID application, the one that you received while Bot creation.
In Client Secret field put your password for application.

Specify received webhook-url of process in settings of your bot in My bots tab, in Messaging endpoint field. More details here.

What BitcoinBot does

BitcoinBot for new contacts sends information about bot to Send info about bot. node.

Sends message of currency selection by start command.

After selection of currency for getting converting rates, BitcoinBot makes a request to API blockchain and sends a message with buy and sell currency in selected currency.

BitcoinBot sends appropriate message in case of getting uncertain command and in case of error in process.

Testing and launch

Just add your Bot to Skype by link of from bot's catalog (if bot is published) and start chat.

screen_en_bitcoin

Switch to View or Debug mode to see request flow, its origin and process nodes distribution.
view_bitcoin


Was this article helpful?