Help regarding a chat workflow

Hey Everyone, I’m building a workflow for telegram bot as follow:

1- Send command from telegram bot

2- pipedream trigger for the event

3- pipedream send a text message as “Enter name”

how can I add in the workflow the next text to be received or how can I add a trigger event to proceed with more steps?

Hi @Razzor

First off, welcome to the Pipedream community. Happy to have you!

Great question. I assume you’ve already created your bot via the Telegram BotFather.

Next you’ll need to register your command on your bot with the BotFather:

  1. Open a chat with the BotFather
  2. Send the command /mybots
  3. Choose your bot
  4. Select Edit Commands
  5. Define your command

Then in your Pipedream Telegram trigger, you can detect commands vs normal messages using the entities property in the Telegram message from the user:

CleanShot 2022-08-12 at 11.51.20

If steps.trigger.event.entities includes a { type: 'bot_command' } then you know you should reply with a message.

Then you can send a reply, below I’m using a pre-built action:

Note: I added the ForceReply option to make the user respond with a reply to the prompt:

CleanShot 2022-08-12 at 11.53.31

Then you’ll have to conditionally accept this answer and move onto the next.

I would recommend using a Node.js or Python step to act as the “chat router”, and store the message_id of the user’s responses in a Data Store.

Hi Piecre,

There is great workmanship in your message. Pipedream has excellent features. :heart:

I’m trying to understand everything. I think the following scenario is possible;

I have a telegram bot, I added it to a channel, and we can auto-reply to a command or message called /hi?

Hi @ryanggunner

Thanks for reaching out, yes that scenario is definitely possible.

You’ll have to first use the BotMaster to add a new command to your pre-existing bot.

Then in Pipedream follow the directions I have described above.

Then in the workflow, you can use the steps.trigger.event.text to determine which slash command the user initiated.

I’ll be making a short video on how to do this as well. Hope you don’t mind a shout out.

Yes please make a video, ser.
You say it’s very easy to do. but I can’t.
Im 40 yo. I even started learning node.js to be able to do this.
It’s not easy to deal with codes. I respect you!

If it is difficult to make a video, can you send me a detailed e-mail? Pls

btw, I learned to write a code in node.js below
I wrote this so you know I’m not lazy and trying to learn :slight_smile:

bot.hears(‘/today’, (ctx)=> [
ctx.reply(‘Todays Launch List’)

Hi @ryanggunner

Here’s a tutorial: Adding commands to a Telegram Bot with Pipedream Workflow

And the corresponding video: Speed Run #28 - Add commands to a Telegram Bot - YouTube

You can copy my workflow with this link:

Hope this helps! Let me know if you have any questions.

1 Like

Thank you :heart:
This really helped a lot. :pray:
It’s great that you make a video and respond in such a short time.
You are a great person. and Pipedream awesome!

1 Like

Hi @pierce

The bot works fine, responds to my commands as I want. and more. :slight_smile:
When I interact with the bot’s posts(reply,quote) to the Channel, it resends the message. How do I prevent it from doing this?

I couldn’t find if this is due to telegram bot api or is it related to codes, I’m researching :face_with_monocle:

Hmm, I looked at Inspector a bit. unlike normal trigger
''reply_to_message {6} ‘’ appears.

i think this is related to update type - message

Thanks again.

Hi @ryanggunner

Glad to hear the example unblocked you.

So you’ll need to use the Node.js code step to exit the workflow early on Telegram messages that shouldn’t trigger a reply.

Here’s the code from the video, with an example of exiting the workflow early using $.flow.exit():

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    if(steps.trigger.event.message.text == '/hi') {
      return 'Hi from Pipedream AGAIN';
    } else if(steps.trigger.event.message.text == '/bye') {
      return 'Bye nice to see ya come again soon';
    } else {
       $.flow.exit("Not a recognized command, exiting early");

Here’s documentation on how to use $.flow.exit.

1 Like

Based on my experience building a Telegram bot slash command from the video walkthrough, I think a new trigger can be added to only listen to bot slash commands, instead of all messages.

I’ve opened up an issue here:

1 Like