Register For Our Live Webinar WorkshopRegister Now

Technology trends, insights, success
stories and other helpful resources.

Integrate Dynamics NAV with Telegram

January 20th, 2017 Intech SystemIntech System Dynamics NAV, Microsoft Dynamics

As we all know that BOTs are the most buzz topic now-a-days and Telegram messaging application has a good hold
on it as a platform. Recently we  received a couple of feedback from our customers to integrate some messaging
application with Dynamics NAV because that’s where they work-in the whole day and they don’t like to switch the screen to connect with their co-workers. We had been searching a good BOT to integrate with our ERP until we ended up crafting it on Telegram. It’s very easy and fun work.
Easiest Steps to Integrate Telegram with Microsoft Dynamics NAV

  1. Connect to @BotFather account of Telegram by searching like thisbotfather account telegram

2. Create new bot by sending /newBot command

create new bot command

3. It will ask for your Bot name that you want to create.

Your Bot name

4. Give Suitable name that ends with for Ex: NAV_bot.

bot name

5. Each bot is given a unique authentication token when it is created. The token looks something like 326076132:AAEufsce4s2sg5b6mdbmW_KLTcbmS-HeVXY.

  • To generate token, just go into botFather account.
  • Send /token

 

unique authentication token

  • It will ask you that, for which bot you want to generate token.

 

bot token

  • Just Tap on our newly created bot name @Navision_bot.

 

newly created Bot name

  • That’s it, just copy this token for your reference.

6. Now, I have created this bot to Integrate with NAVISION, so for that you require to generate Chat IDs of users to send chat messages to any Telegram User.

  • First of all, users will have to send test message to the BOT that you created.
  • For that, search your bot account in Telegram starts with @ Sign followed by your Bot Name.

 

Search your bot account

  • Just enter into your bot, and type /Start to send test message to generate your Chat ID.

 

Generate Chat ID

  • Now, your Chat ID generated and you will get it by calling getUpdates method of Telegram API, for this you have to call getUpdates method in web browser as follows.
  • https://api.telegram.org/bot<Your Bot Name>/getUpdates
  • For Ex: https://api.telegram.org/324480200:AAGxuzqskveyV-ZBTM81P0CCI2qartfWPfo/getUpdates
  • You will see the response of telegram in JSON format as follows.

 

response of telegram-JSON format

  • From here you can get the Chat IDs.

7. All set, now you can send message to any user. And it will have sent from your newly created

  • To Integrate Telegram with NAV, we have focused to send requests via CURL tool, that silently run HTTP requests from
  • For Ex:
  • Open CMD.
  • Go to the path where your CURL tool is there.
  • Run the command to send Http Post request like this: Curl -X POST “https://api.telegram.org/bot326076132:AAEufscs4s2sg5b6mEbmW_KLTcbmS-HeVXY/sendMessage” -d “chat_id=163898670&text=my sample text”

 

send HTTP Post request

 

All Above Steps are to test sample message sending from HTTP request.
8. Now to Integrate Telegram with NAV, you will have to send HTTP requests from NAV code, For that, I have used CURL tool that run silently from your PC and sends HTTP request.
9. Create One Automation variable of ‘Windows Script Host Object Model’.WshShell to open CMD and run CURL command.
10. Here are some sample commands to send messages and send attachments from NAV.

  • curl -X POST “https://api.telegram.org/bot326076132:AAEufccs4s2kg5b6mfbmW_KLTcbmS-HeVXY/sendMessage” -d “chat_id=-189801512&text=my sample text”
  • curl -F chat_id=”35065383″ -F document=@”//intechserver/Shared/FTP/Attachments/Temp.pdf” -F caption=”PFA” https://api.telegram.org/bot326076132:AAEufscs4s2sg5b6mEbmW_KLTcbmS-HeVXY/sendDocument
  • just run above commands from NAV with the use of Automation variable.

11. Just create Two tables, one is for chat IDs for individual NAV users and another is to create telegram message queue.

  1. Chat IDs table will contain user ID and Chat ID fields.
  2. Message queue table will contain User ID of receiver, attachment, Message body fields.
  3. Now do code for send message Action with the use of above automation variable and CMD command as above.

12. Final NAV will look like this,

Final NAV look

This page contains Chat IDs of Individual Users in NAV.

Chat ID in NAV
Chat ID

This Page will send Message to particular User that was added in Chat IDs table.
Just place sendMessage code on this Send Message Action

send message

You can keep Sent Message Entries by creating another page like this.

If you need any help, feel free to reach us.

Recent Post

Corporate Profile

Request Demo Download Brochure
Contact Us

How we can help you!

Talk to Dynamics 365 experts for your concerns

Contact Us
Contact Us

How can we help? - Talk to Dynamics 365 experts for your concerns

    Join our mailing list for news updates, invitations, and more