Deeplink / Referal
Kuliah singkat mengenal deeplink dan implementasinya
1 menit dibaca
Materi ada pada video, belum sempat dibuat berupa tulisan.
Silakan ditonton yak!
Video
Source Code
Berikut ini source code pada video.
Sumber: Gist - Github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const button = lumpia.button; | |
const markup = lumpia.markup; | |
const helper = lumpia.helper; | |
bot.options.username = 'belajarGASbot'; | |
/* | |
Contoh kasus: membuat template pesanan user | |
Link: https://t.me/belajarGASbot?start=order | |
*/ | |
bot.start(ctx => { | |
let payload = ctx.payload; | |
if (!payload) { | |
let pesan = '<b>Selamat datang</b>, di bot Kita !!'; | |
pesan += '\n\n ✅ KLIK <a href="https://t.me/belajarGASbot?start=order">ORDER</a>'; | |
pesan += '\n\n ✅ KLIK <a href="https://t.me/belajarGASbot?start=kode123">Info Modem</a>'; | |
pesan += '\n\n ✅ Kode Refferalmu: https://t.me/' + bot.options.username | |
pesan += '?start=ref' + ctx.from.id; | |
return ctx.replyWithHTML(pesan, { | |
disable_web_page_preview: true | |
}); | |
} | |
var pola = /^ref(\w+)/i; | |
var cocok; | |
if (cocok = pola.exec(payload)) { | |
// terserah teman-teman | |
// kode ref nya mau diolah seperti apa | |
return ctx.reply('Kode referalnya adalah: ' + cocok[1]); | |
} | |
if (payload == 'order') { | |
let formatOrder = `\n | |
Nama: | |
Alamat: | |
Jumlah barang: | |
Mohon segera diproses yak...! | |
`; | |
let pesan = 'Masukkan format seperti berikut ini' + formatOrder; | |
return ctx.reply(pesan); | |
} | |
if (payload == 'kode123') { | |
let pesan = 'Informasi Barang Kode 123, adalah:'; | |
pesan += `\n | |
Nama Produk: Modem ABC-123 | |
Warna: Hitam | |
KCU: AA112233 | |
Harga: Rp. 230.000,00 | |
Untuk lebih lengkapnya, silakan buka web https://banghasan.com | |
`; | |
return ctx.reply(pesan, { | |
disable_web_page_preview: true | |
}); | |
} | |
if (payload == 'waktu') { | |
let pesan = Utilities.formatDate(new Date(), 'GMT+7', 'HH:mm:ss') + ' WIB.' | |
return ctx.reply(pesan); | |
} | |
let pesan = "Payloadnya adalah: " + ctx.payload; | |
ctx.reply(pesan); | |
}) | |