Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions chatbot.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
69 changes: 69 additions & 0 deletions intro_al_botfatheR.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: "Como usar el chatbot de Telegram con R"
author: "ixpantia"
date: "10/10/2020"
output: html_document
editor_options:
chunk_output_type: console
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(telegram.bot)
```

## Introduccion

Quereomos usar Telegram

## Un simple ejemplo

```{r}
TOKEN <- Sys.getenv("TOKEN")

start <- function(bot, update) {
bot$sendMessage(
chat_id = update$message$chat$id,
text = sprintf("Hola %s! \n
este es un mensaje de varias \n
si varias \n
lineas", update$message$from$first_name)
)
}

updater <- Updater(TOKEN) + CommandHandler("start", start)

updater$start_polling() # Send "/start" to the bot

```


## Ahora con dos comandos

```{r}
TOKEN <- Sys.getenv("TOKEN")

start <- function(bot, update) {
bot$sendMessage(
chat_id = update$message$chat$id,
text = sprintf("Hola %s! acabas de comuncarte con el Chatbot de ConectaR2021. Usted tiene el control sobre este chatbot, haciendo sus consultas con los siguientes comandos. ..... ", update$message$from$first_name)
)
}


hola <- function(bot, update) {
bot$sendMessage(
chat_id = update$message$chat$id,
text = sprintf("Hola este es el chatbot de la conferencia ConectaR2021. Puedes usar esto para obtener informacion sobre lo que estamos haciendo. Para ver las diferentes opciones usa el /en este momento tenemos /info /programa. ",
update$message$from$first_name)
)
}

updater <- Updater(TOKEN) + CommandHandler("start", start)
updater <- Updater(TOKEN) + CommandHandler("hola", hola)

updater$start_polling() # Send "/start" to the bot

```